package com.example.backend.service.impl;



import com.example.backend.mapper.ComplainMapper;
import com.example.backend.mapper.OrderMapper;
import com.example.backend.pojo.Complain;
import com.example.backend.service.ComplainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComplainServiceImpl implements ComplainService {
    @Autowired
    private ComplainMapper complainMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public List<Complain> getallbyuserid(Integer userid) {
        return complainMapper.getallbyuserid(userid);
    }




    @Override
    public void addcomplain(Complain complain) {
        complainMapper.addcomplain(complain);
        orderMapper.updatecomplain(complain.getComplainid(),complain.getOrderid());

    }


    @Override
    public void statechange(Integer complainid, Integer state) {
        complainMapper.statechange(complainid,state);
    }

    @Override
    public List<Complain> getstate(String restaurantid,Integer state) {
        return complainMapper.getstate(restaurantid,state);
    }

    @Override
    public void accept(Complain complain) {
        complainMapper.accept(complain);
    }

    @Override
    public void retry(Complain complain) {
        complainMapper.retry(complain);
        orderMapper.updateorder(String.valueOf(complain.getOrderid()),2);

    }

    @Override
    public Complain getByid(Integer complainid) {
        return complainMapper.getByid( complainid);
    }
}
